﻿@{
    ViewBag.Title = "createOrder";
}

<h2> Create Order</h2>
<form>
    The name of the factory: <input type="text" id="factoryName" autocomplete="off" /><br>
    <input type="button" id="get data" value="get datas" onclick="getDatas()" /><br>
    The name of the product:
    <select>
        <option value="drill">Drill</option>
        <option value="polisher">Polisher</option>
        <option value="twist">Twist</option>
    </select><br>
    Quantity :<input type="number" id="quantity" min="1" autocomplete="off" /><br>
    Price : <input type="number" id="price" min="1" value="getPrice()" readonly autocomplete="off" /><br>
    The reach of the product: <br>
    In warehouse, we can inmediate ship (Quantity) <br>
    <input type="text" id="warehouse" readonly autocomplete="off" /><br>
    Factory, in which we can inmediate reach the whole amount of the product in warehouse: <br>
    <input type="text" id="factory" readonly autocomplete="off" /><br>
    <input type="button" id="orderButton" value="order" onclick="order()" />

</form>

<script>
    function getPrice() {
        return 5;
    }
    function getDatas() {
        factoryName = document.getElementById("factoryName");
        if (factoryName.value == "") {
            alert("You must give the name of the factory");
            return;
        }
        if (factoryName.value.search(/\d/i) != -1) {
            alert("Do not give number to name");
            factoryName.value = "";
            return;
        }
        factoryName.value = "";
    }
    function order() {
        if (factoryName.value == "") {
            alert("You must give the name of the factory");
            return;
        }
        if (factoryName.value.search(/\d/i) != -1) {
            alert("Do not give number to name");
            factoryName.value = "";
            return;
        }
        quantity = document.getElementById("quantity");

        if (quantity.value == "") {
            alert("You must give the quantity");
            return;
        }
        factoryName.value = "";
        quantity.value = "";
        factoryName.value = "";
        document.getElementById("price").value = "";
        document.getElementById("warehouse").value = "";
        document.getElementById("factory").value = "";
        alert("Your oder is OK");
    }
</script>